package com.iot.core.base;

import lombok.Getter;

import javax.jms.Message;

@Getter
public class IotMessage {
    private final Message message;
    private final String messageId;
    private final String topic;
    private final String payload;

    public IotMessage(Message message) {
        try {
            this.message = message;
            this.messageId = message.getJMSMessageID();
            this.topic = message.getStringProperty("topic");
            this.payload = new String(message.getBody(byte[].class));
        } catch (Throwable e) {
            throw new RuntimeException("消息解析异常：" + e);
        }
    }
}
